<?php
/**
 * @file
 * 
 */

/* Load required lib files. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
$update=$_GET['status'];
$submit=$_GET['submit'];
$network_id=$_GET['network_id'];
$access_token = array(
	'oauth_token'=>$_GET['oauth_token'],
	'oauth_token_secret'=>$_GET['oauth_token_secret']
	);
/* If access tokens are not available redirect to connect page. */
/* Get user access tokens out of the session. */

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

/* If method is set change API call made. Test is called by default. */
$content = $connection->get('account/rate_limit_status');
$API_status = "Current API hits remaining: {$content->remaining_hits}.";

/* Get logged in user to help with tests. */
$user = $connection->get('account/verify_credentials');

date_default_timezone_set('GMT');

if($update != "" && $submit != ""){
$reply_to=$_POST['in_reply_to'];
if($reply_to == ""){
$parameters = array('status' => $update);
}else{
$parameters = array('status' => $update, 'in_reply_to_status_id'=>$reply_to);
}
$status = $connection->post('statuses/update', $parameters);
$terkirim = $status->text;
}
header('Location: ../manage_network/twitter/'.$network_id);

